package com.hgkj.cloud.customer.controller;

import com.hgkj.cloud.base.service.TenantOrderInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/psyOrder")
public class PsyOrderController {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private TenantOrderInfoService tenantOrderInfoService;

    @RequestMapping("/sendEmail")
    @ResponseBody
    public void sendEmail() {
        Map<String,Object> map = new HashMap<>();
        try {
            List<Map<String,Object>> list = tenantOrderInfoService.getAllPsyEmail(map);
            for (int i=0; i< list.size();i++) {
                Map<String,Object> sub = list.get(i);
                String toEmail = sub.get("email").toString();
                String subject = "预约咨询提醒";
                String adminRealName = sub.get("admin_real_name").toString();
                String result = sub.get("result").toString();
                result = result.replace("--###$$$###--","\r\n");
                String content = adminRealName +"你好,今天你有咨询任务，结果如下：\r\n" + result + "\r\n,请注意查看！";
                //MailUtil.sendEmail(toEmail,subject,content);
            }
            logger.info("发送咨询邮件提醒");
        } catch (Exception e) {
            logger.error("发送咨询邮件提醒异常");
            e.printStackTrace();
        }
    }
}
